﻿


<div ms-controller="tmpmodelview">
    <div class="control-group">
        <label class="control-label"><b style="color: #f00;">*</b>视频类型：</label>
        <div class="controls">
            <select class="input-medium input-xfat" ms-duplex="modelData.VideoType">
                <option value="1">分类视频</option>
                <option value="2">华豫学院</option>
            </select>
           <span ms-visible="modelData.VideoType=='2'">课程：</span> <select class="input-large input-xfat" ms-duplex="modelData.InfoID" ms-visible="modelData.VideoType=='2'">
                   <option ms-repeat-el="CatData2" ms-attr-value="el.ID" ms-attr-selected="modelData.InfoID==el.ID?'selected':''">{{el.Title}}</option>
                  </select>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label"><b style="color: #f00;">*</b>原始视频：</label>
        <div class="controls">
            <select class="input-xlarge input-xfat" ms-duplex="modelData.SourceName">

                <option ms-repeat-el="ListData1" ms-attr-value="el" ms-attr-selected="modelData.SourceName==el?'selected':''">{{el}}</option>
            </select>
        </div>
    </div>

    <div class="control-group">
        <label class="control-label v-top">
            <b style="color: #f00;">*</b>
            切片标题：
        </label>
        <div class="controls">
            <input type="text" class="input-xlarge input-xfat" ms-duplex="modelData.Title" data-rules="required" maxlength="200">
        </div>
    </div>
    <div class="control-group">
        <label class="control-label"><b style="color: #f00;">*</b>分类：</label>
        <div class="controls">
            <select class="input-medium input-xfat" ms-duplex="modelData.Type1">
               
                <option ms-repeat-el="CatData1" ms-attr-value="el.ID" ms-attr-selected="modelData.Type1==el.ID?'selected':''">{{el.TypeName}}</option>
            </select>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">开始时间：</label>
        <div class="controls" id="v_timestart">
            <input class="input-small input-xfat" type='number' value="0" max="23" min="0" />:<input class="input-small input-xfat" type='number' value="0" max="59" min="0" />:<input class="input-small input-xfat" type='number' value="0" max="59" min="0" />
            <span style="color:red;">时:分:秒</span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">结束时间：</label>
        <div class="controls" id="v_timeend">
            <input class="input-small input-xfat" type='number' value="0" max="23" min="0" />:<input class="input-small input-xfat" type='number' value="0" max="59" min="0" />:<input class="input-small input-xfat" type='number' value="0" max="59" min="0" />
            <span style="color:red;">时:分:秒</span>
        </div>
    </div>
    <!--<div class="control-group">
        <label class="control-label">自动截图：</label>
        <div class="controls">
            <select ms-duplex="modelData.AutoImg">
                <option value="是">是</option>
                <option value="否">否</option>
            </select>
        </div>
    </div>-->
    <div class="control-group">
        <label class="control-label v-top">
            视频图片(750*340)：
        </label>
        <div class="controls" style="width:900px">
            <ul class="sui-row-fluid" id="layer-photos-demo">
                <li class="span2" ms-repeat-el="FileData">
                    <div class="img-round">
                        <img ms-attr-layer-src="{{ComFunJS.FilePath(el.ID)}}" ms-attr-data-id="el.ID" ms-attr-src="ComFunJS.FilePath(el.ID,'/100/100')" alt="">
                    </div>
                    <label>
                        <label> <a href="javascript:void(0);" class="sui-btn btn-bordered btn-small btn-danger" ms-click="DelFile(el)">删除</a> </label>
                    </label>
                </li>
                <li class="span2">
                    <button ms-click="FileUpload()" style="margin:15px 0" class="sui-btn btn-xlarge btn-success">添加图片</button>
                </li>
            </ul>
        </div>
    </div>
    

</div>



<script type="text/javascript">
    var tempmodel = avalon.define({
        $id: "tmpmodelview",
        ListData1:[],
        modelData: { "VideoType": "1", "Type1": "", "SourceName": "", "Title": "", "AutoImg": "是", "ImgUrl": "", "TimeStart": "", "TimeEnd": "", "Status": "0", "Details": "", "InfoID": "0" },
        ClientData: [],
        CatData1: [],
        CatData2: [],
        Init: function (ID) {

            $.getJSON("/adapi/video/osslist", function (r) {
                tempmodel.ListData1 = r.result;
            })

            $.getJSON("/adapi/base/catelist/0", function (r) {
                tempmodel.CatData1 = r.result;
            })
            $.getJSON("/adapi/info/list/3", function (r) {
                tempmodel.CatData2 = r.result;
            })

            if (ID) {
                $.getJSON("/adapi/video/zmmodel/" + ID, function (r) {
                    if (r.error == "") {
                        tempmodel.modelData = r.result;
                        $("#v_timestart").find("input:eq(0)").val(tempmodel.modelData.TimeStart.split(':')[0]);
                        $("#v_timestart").find("input:eq(1)").val(tempmodel.modelData.TimeStart.split(':')[1]);
                        $("#v_timestart").find("input:eq(2)").val(tempmodel.modelData.TimeStart.split(':')[2]);
                        //$("#v_timestart").find("input:eq(4)").val(tempmodel.modelData.TimeStart.split(':')[1]);

                        $("#v_timeend").find("input:eq(0)").val(tempmodel.modelData.TimeEnd.split(':')[0]);
                        $("#v_timeend").find("input:eq(1)").val(tempmodel.modelData.TimeEnd.split(':')[1]);
                        $("#v_timeend").find("input:eq(2)").val(tempmodel.modelData.TimeEnd.split(':')[2]);
                        //$("#v_timeend").find("input:eq(4)").val(tempmodel.modelData.TimeEnd.split(':')[1]);

                        pmodel.FileData = ComFunJS.strToIds(r.result.ImgUrl);
                        setTimeout("ComFunJS.initForm();", 500);
                    }

                })
            } else {
                if (localStorage.getItem("tmpzmmodel")) {
                    var d = JSON.parse(localStorage.getItem("tmpzmmodel"));
                    if (d) {
                        tempmodel.modelData.InfoType = d.InfoType;
                        tempmodel.modelData.Type1 = d.Type1;
                        tempmodel.modelData.SourceName = d.SourceName;
                        tempmodel.modelData.InfoID = d.InfoID;

                    }

                }
                ComFunJS.initForm();
            }

        },
        tmpSaveData: function () {
            var h1 = $("#v_timestart").find("input:eq(0)").val();
            var m1 = $("#v_timestart").find("input:eq(1)").val();
            var s1 = $("#v_timestart").find("input:eq(2)").val();
            //var ms1 = $("#v_timestart").find("input:eq(3)").val();

            //判断格式
            $("#v_timestart").find("input").each(function (index, item) {
                if ($(item).val() == "" || $(item).val().length > 2) {
                    top.ComFunJS.winShowMsg("时间格式错误");
                    return;
                }

            })
            $("#v_timeend").find("input").each(function (index, item) {
                if ($(item).val() == "" || $(item).val().length > 2) {
                    top.ComFunJS.winShowMsg("时间格式错误");
                    return;
                }

            })

            tempmodel.modelData.TimeStart = h1 + ":" + m1 + ":" + s1;

            var h2 = $("#v_timeend").find("input:eq(0)").val();
            var m2 = $("#v_timeend").find("input:eq(1)").val();
            var s2 = $("#v_timeend").find("input:eq(2)").val();
            //var ms2 = $("#v_timeend").find("input:eq(3)").val();

            tempmodel.modelData.TimeEnd = h2 + ":" + m2 + ":" + s2;

            tempmodel.modelData.ImgUrl = pmodel.GetFileIds();

            localStorage.setItem("tmpzmmodel", JSON.stringify(tempmodel.modelData.$model));

            $.post("/adapi/video/addzm", tempmodel.modelData.$model, function (r) {
                if (r.error == "") {
                    top.ComFunJS.winShowMsg("操作成功");
                    top.ComFunJS.close();
                } else {
                    top.ComFunJS.winShowAlert(r.error);
                }

            })
        }

    });


</script>




